<template>
    <div class="layout-route">
        <div class="card card-search">
            <el-form :model="queryParams" ref="queryForm" v-show="showSearch" inline label-width="100px">
                <el-form-item label="采购单号" prop="purchase_number">
                    <el-input v-model.trim="queryParams.purchase_number" placeholder="请输入" clearable style="width: 240px" @keyup.enter.native="handleQuery" />
                </el-form-item>
                <el-form-item label="签收时间" prop="create_time">
                    <el-date-picker v-model="queryParams.create_time" type="date" placeholder="请选择签收时间" clearable style="width: 240px"> </el-date-picker>
                </el-form-item>
                <el-form-item label=" ">
                    <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
                    <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
                </el-form-item>
            </el-form>
        </div>

        <div class="card">
            <!-- <el-row :gutter="10" class="mb8">
              <el-col :span="1.5">
                  <el-button type="primary" plain icon="el-icon-plus" @click="showDetailDialog({})">新增</el-button>
              </el-col>
              <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
          </el-row> -->
          <el-table v-loading="loading" :data="tableData" border script>
                <el-table-column label="ID" prop="id" width="55"></el-table-column>
                <el-table-column label="采购单号" prop="purchase_number"></el-table-column>
                <el-table-column label="运单号" prop="track_number"></el-table-column>
                <el-table-column label="签收时间" prop="create_time"></el-table-column>
                <el-table-column label="仓库" prop="warehouse"></el-table-column>
                <el-table-column label="签收人" prop="operater"></el-table-column>
            </el-table>

            <pagination v-show="total > 0" :total="total" :page.sync="pageInfo.page" :limit.sync="pageInfo.limit" @pagination="getList"></pagination>
        </div>
        <detail-dialog v-model="detailDialog.visible" v-if="detailDialog.visible" :params="detailDialog.data" @success="handleQuery"></detail-dialog>
    </div>
</template>

<script>
import { in_store_log } from '@/api/purchase'
import { parseTime } from '@/utils/quickadmin'
export default {
    name: 'StockList',
    components: {},
    data() {
        return {
            // 遮罩层
            loading: true,
            // 显示搜索条件
            showSearch: true,
            // 总条数
            total: 0,
            // 表格数据
            tableData: [],
            // 店铺列表下拉
            shopList: [],
            siteList: [],
            pageInfo: {
                page: 1,
                limit: 10,
            },
            // 查询参数
            queryParams: {
                in_number: undefined,
                purchase_number: undefined,
                create_time: undefined,
            },
            detailDialog: {
                visible: false,
                data: {},
            },
        }
    },
    created() {
        this.getList()
    },
    methods: {
        //列表
        getList() {
            this.loading = true
            const qyparams = {
                ...this.pageInfo,
                ...this.queryParams,
                create_time: this.queryParams.create_time ? parseTime(this.queryParams.create_time, 'y-m-d h:i:s') : ''
            }
            in_store_log(qyparams)
                .then(response => {
                    this.tableData = response.data.list
                    this.total = response.data.total
                })
                .finally(() => {
                    this.loading = false
                })
        },

        // 搜索按钮操作
        handleQuery() {
            this.pageInfo.page = 1
            this.getList()
        },

        // 重置按钮操作
        resetQuery() {
            this.resetForm('queryForm')

            this.handleQuery()
        },
    },
}
</script>
